package com.csf.struct.composite;

import java.util.Enumeration;
import java.util.Vector;

/**
 * TODO ADD DESCRIPTION
 * Date: 2018/9/6
 * Time: 17:11
 *
 * @author chenshf
 */
public class TreeNode {

    private String name;

    private TreeNode parent;

    private Vector<TreeNode> nodeList = new Vector<>();

    public TreeNode(String name){
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public TreeNode getParent() {
        return parent;
    }

    public void setParent(TreeNode parent) {
        this.parent = parent;
    }

    public Vector<TreeNode> getNodeList() {
        return nodeList;
    }

    public void setNodeList(Vector<TreeNode> nodeList) {
        this.nodeList = nodeList;
    }

    public void addChild(TreeNode node){
        node.setParent(this);
        nodeList.add(node);
    }

    public void removeChild(TreeNode node){
        nodeList.remove(node);
    }

    public Enumeration<TreeNode> getChilds(){
        return nodeList.elements();
    }
}
